
package com.yyfax.ph.personal.settings;

import android.os.Parcel;
import android.os.Parcelable;
import com.yyfax.common.CLog;
import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.infrastructure.network.entity.EmptyEntity;
import com.yyfax.ph.base.YJPH;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * 获取公司
 * Created by zhangxian on 2017/11/1.<br>
 * Copyright 2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class GetCompanyModel extends Model {
	private static final String TAG = GetCompanyModel.class.getSimpleName();
	public static final int MSG_CHECK_BIND_COMPANY = 52;

	//0:已绑定 1：无绑定  2:申请中
	public static final String STATUS_BIND = "0";
	public static final String STATUS_NOT_BIND = "1";
	public static final String STATUS_APPLYING = "2";
	public static final String STATUS_NONE = "-1";

	@Override
	public void onNext(Object obj) {
		CLog.i(TAG, "onNext: " + obj.toString());

		CompanyResult company = cast(obj);
		EventAgent.post(company);
	}

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		String token = YJPH.getInstance().getPreferenceManager().getLoginToken();
		return service.getCompanyInfo(token, new EmptyEntity());
	}

	public interface Service {
		@POST("account/bind/getCompany")
		Observable<CompanyResult> getCompanyInfo(@Header("token") String token, @Body EmptyEntity params);
	}

	public static class CompanyBean {
		public String companyName;
		public String applyName;
		public String status;
		public String phone;
	}

	public static class CompanyResult extends BaseResultEntity<CompanyBean> {
	}

}
